package net.apexes.demo.codegen.ormlite.column;

import net.apexes.commons.ormlite.Column;
import net.apexes.commons.ormlite.Index;
import net.apexes.demo.codegen.ormlite.column.base.QEntityBase;
import net.apexes.demo.codegen.ormlite.entity.Sources;

/**
 * QSources is a ORMLite query type for Sources
 * @see Sources
 */
public class QSources extends QEntityBase<Sources> {

    public static final QSources $ = new QSources("SOURCES");

    public final Column name = field("name").columnName("NAME").varchar(32).notNull().build();

    public final Column sourcesType = field("sourcesType").columnName("SOURCES_TYPE").varchar(1).notNull().build();

    public final Column templateId = field("templateId").columnName("TEMPLATE_ID").varchar(22).notNull().build();

    public class Indexs {

        public final Index primaryKeyB2 = index("PRIMARY_KEY_B2").unique().column(id).build();

    }

    public final Indexs ix = new Indexs();

    public QSources(String tableName) {
        super(Sources.class, tableName);
    }

    @Override
    public Sources newInstance() {
        return new Sources();
    }

    @Override
    public Object getFieldValue(Sources instance, String fieldName) {
        switch (fieldName) {
            case "name":
                return instance.getName();
            case "sourcesType":
                return instance.getSourcesType();
            case "templateId":
                return instance.getTemplateId();
            default:
                return super.getFieldValue(instance, fieldName);
        }
    }

    @Override
    public void setupFieldValue(Sources instance, String fieldName, Object value) {
        switch (fieldName) {
            case "name":
                instance.setName((java.lang.String) value);
                break;
            case "sourcesType":
                instance.setSourcesType((java.lang.String) value);
                break;
            case "templateId":
                instance.setTemplateId((java.lang.String) value);
                break;
            default:
                super.setupFieldValue(instance, fieldName, value);
                break;
        }
    }

}

